package cn.tedu.charging.device.controller;


import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "设备模块")
@Slf4j
@RequestMapping("device")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")

    public JsonResult<StationInfoVO> getStationInfo(@PathVariable Integer gunId) {
        log.info("获取场站信息-入参:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        log.info("获取场站信息-入参:{},出参:{}",gunId,stationInfoVO);
        JsonResult<StationInfoVO> result = JsonResult.ok(stationInfoVO, "获取场站信息成功");
        log.debug("获取场站信息-入参:{},出参:{}",gunId,result);
        return result;
    }
    @ApiOperation("更新枪状态")
    @PostMapping("/station/gun/status/update")

    public JsonResult<Boolean> upDateGunStatus(@RequestBody GunStatusUpdateParam param) {
        log.info("更新枪状态-入参:{}",param);
        Boolean success = deviceService.upDateGunStatus(param);
        log.info("更新枪状态-入参:{},出参:{}",param,success);
        JsonResult<Boolean> result = JsonResult.ok(success, "更新枪状态成功");
        log.debug("更新枪状态-入参:{},出参:{}",param,result);
        return result;
    }
}
